package com.example.sport.dao;

import com.example.sport.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

    //根据用户名查询用户
    @Select("select * from easyuser where username = #{username}")
    public User getUserByName(String username);

    //模糊分页查询用户
    @Select("select * from easyuser where username like #{username} limit #{pageStart},#{pageSize}")
    public List<User> getAllUser(String username,@Param("pageStart") int pageStart,@Param("pageSize") int pageSize);

    //查询用户个数
    @Select("select count(*) from easyuser where username like #{username}")
    public int getUserCounts(String username);

    //更新用户状态
    @Update("update easyuser set state = #{state} where id = #{id}")
    public int updateState(int id,boolean state);

    //添加新用户
    @Insert("insert into easyuser values(null,#{username},#{password},#{email},#{role},#{state})")
    public int addUser(User user);

    //删除用户
    @Delete("delete from easyuser where id = #{id}")
    public int deleteUser(int id);

    //根据id查询用户
    @Select("select * from easyuser where id = #{id}")
    public User getUserById(int id);

    //修改用户信息
    @Update("update easyuser set username = #{username},password = #{password},email = #{email} where id = #{id}")
    public int updateUser(User user);

}
